﻿//$(function () {

//    $('#da-slider').cslider({
//        autoplay: true,
//        bgincrement: 450
//    });

//});

//slide
(function ($) {

    $(document).ready(function () {
        $('.slides').iView({
        });
    });

})(jQuery);

//back to top
function checkSH(time) {
    if ($(window).scrollTop() == 0) {
        $('#go_top').stop(false, true).fadeOut(time);
    } else {
        $('#go_top').stop(false, true).fadeIn(time);
    }
}

$(document).ready(function () {
    checkSH(0);
    $(window).scroll(function () {
        checkSH(600);
    });

    $("#go_top").click(function () {
        $('html, body').animate({ scrollTop: 0 }, 'slow');
    });
});

//jquery selectbox
$(document).ready(function () {
    enableSelectBoxes();
});

function enableSelectBoxes() {
    $('div.selectBox').each(function () {
        $(this).children('span.selected').html($(this).children('div.selectOptions').children('span.selectOption:first').html());
        $(this).attr('value', $(this).children('div.selectOptions').children('span.selectOption:first').attr('value'));

        $(this).children('span.selected,span.selectArrow').click(function () {
            if ($(this).parent().children('div.selectOptions').css('display') == 'none') {
                $(this).parent().children('div.selectOptions').css('display', 'block');
            }
            else {
                $(this).parent().children('div.selectOptions').css('display', 'none');
            }
        });

        $(this).find('span.selectOption').click(function () {
            $(this).parent().css('display', 'none');
            $(this).closest('div.selectBox').attr('value', $(this).attr('value'));
            $(this).parent().siblings('span.selected').html($(this).html());
        });
    });
}//-->

//slide
$(function () {
    function mycarousel_initCallback(carousel) {
        // Disable autoscrolling if the user clicks the prev or next button.
        carousel.buttonNext.bind('click', function () {
            carousel.startAuto(0);
        });

        carousel.buttonPrev.bind('click', function () {
            carousel.startAuto(0);
        });

        // Pause autoscrolling if the user moves with the cursor over the clip.
        carousel.clip.hover(function () {
            carousel.stopAuto();
        }, function () {
            carousel.startAuto();
        });
    };

    jQuery(document).ready(function () {
        jQuery('.mycarousel').jcarousel({
            auto: false,
            scroll: 4,
            wrap: 'both',
            easing: 'easeOutBounce',
            animation: 1600,
            initCallback: mycarousel_initCallback
        });
    });
});

$(function () {
    //Best Sale; Best Seller; History Product; More Items; History Detail Product
    //$("#show-group-1").carouFredSel({
    //    width: '100%',
    //    height: 'auto',
    //    scroll: {
    //        items: 4,
    //        easing: "cubic",
    //        duration: 1000
    //    },
    //    auto: false,
    //    pagination: "#pager1",
    //    mousewheel: true,
    //    swipe: {
    //        onMouse: true,
    //        onTouch: true
    //    }
    //});

    //$("#show-group-2").carouFredSel({
    //    width: '100%',
    //    height: 'auto',
    //    scroll: {
    //        items: 4,
    //        easing: "cubic",
    //        duration: 1000
    //    },
    //    auto: false,
    //    pagination: "#pager2",
    //    mousewheel: true,
    //    swipe: {
    //        onMouse: true,
    //        onTouch: true
    //    }
    //});

    //$("#show-group-3").carouFredSel({
    //    width: '100%',
    //    height: 'auto',
    //    scroll: {
    //        items: 4,
    //        easing: "cubic",
    //        duration: 1000
    //    },
    //    auto: false,
    //    pagination: "#pager3",
    //    mousewheel: true,
    //    swipe: {
    //        onMouse: true,
    //        onTouch: true
    //    }
    //});

    //$("#show-group-4").carouFredSel({
    //    width: '100%',
    //    height: 'auto',
    //    scroll: {
    //        items: 4,
    //        easing: "cubic",
    //        duration: 1000
    //    },
    //    auto: false,
    //    pagination: "#pager4",
    //    mousewheel: true,
    //    swipe: {
    //        onMouse: true,
    //        onTouch: true
    //    }
    //});

    //$("#show-group-5").carouFredSel({
    //    width: '100%',
    //    height: 'auto',
    //    scroll: {
    //        items: 4,
    //        easing: "cubic",
    //        duration: 1000
    //    },
    //    auto: false,
    //    pagination: "#pager5",
    //    mousewheel: true,
    //    swipe: {
    //        onMouse: true,
    //        onTouch: true
    //    }
    //});

    $("#history-product").carouFredSel({
        items: {
            visible: 4,
            start: 3
        },
        scroll: {
            easing: "cubic",
            duration: 1000,
            pauseOnHover: true
        },
        auto: {
            timeoutDuration: 1000,
            delay: 3000,
            items: 4,
            duration: 4000,
            easing: "quadratic"
        },
        prev: "#prev-history-product",
        next: "#next-history-product",
        mousewheel: true,
        swipe: {
            onMouse: true,
            onTouch: true
        }
    });

    $("#history-detail-product").carouFredSel({
        items: {
            visible: 5,
            start: 3
        },
        scroll: {
            easing: "cubic",
            duration: 1000,
            pauseOnHover: true
        },
        auto: {
            timeoutDuration: 1000,
            delay: 3000,
            items: 4,
            duration: 4000,
            easing: "quadratic"
        },
        prev: "#prev-history-detail-product",
        next: "#next-history-detail-product",
        mousewheel: true,
        swipe: {
            onMouse: true,
            onTouch: true
        }
    });

    $("#best-sale").carouFredSel({
        items: {
            visible: 4,
            start: 3
        },
        scroll: {
            easing: "cubic",
            duration: 1000,
            pauseOnHover: true
        },
        auto: {
            timeoutDuration: 1000,
            delay: 3000,
            items: 4,
            duration: 4000,
            easing: "quadratic"
        },
        prev: "#prev-best-sale",
        next: "#next-best-sale",
        mousewheel: true,
        swipe: {
            onMouse: true,
            onTouch: true
        }
    });

    $("#best-seller").carouFredSel({
        items: {
            visible: 4,
            start: 3
        },
        scroll: {
            easing: "cubic",
            duration: 1000,
            pauseOnHover: true
        },
        auto: {
            timeoutDuration: 1000,
            delay: 4000,
            items: 4,
            duration: 5000,
            easing: "quadratic"
        },
        prev: "#prev-best-seller",
        next: "#next-best-seller",
        mousewheel: true,
        swipe: {
            onMouse: true,
            onTouch: true
        }
    });

    $("#more-items").carouFredSel({
        items: {
            visible: 5,
            start: 3
        },
        scroll: {
            easing: "cubic",
            duration: 1000,
            pauseOnHover: true
        },
        auto: {
            timeoutDuration: 1000,
            delay: 3000,
            items: 5,
            duration: 4000,
            easing: "quadratic"
        },
        prev: "#prev-more-items",
        next: "#next-more-items",
        mousewheel: true,
        swipe: {
            onMouse: true,
            onTouch: true
        }
    });
});

//nav-menu
$(function () {
    $('.nav-menu > li').find('ul.nav-1').each(function () {
        $(this).parent().addClass('lv1');
    })

    $('.lv1 > a').click(function (e) {
        e.preventDefault();
        el = $(this);
        if (!el.hasClass('on')) {
            $('.on').removeClass('on').next().stop(false, true).fadeOut(100);
            el.addClass('on').next().stop(false, true).fadeIn(200);
        } else {
            $('.on').removeClass('on').next().stop(false, true).fadeOut(100);
        }
    })
});

(function ($) {

    $(document).ready(function () {
        //profile
        $('a.edit-email').click(function () {
            $('#view-email').addClass('hidden').next().stop(false, true).fadeIn(200);
            $('#edit-email').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#submit').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#edit-email').css('margin-top', '-16px');
        });

        $('a.edit-name').click(function () {
            $('#view-name').addClass('hidden').next().stop(false, true).fadeIn(200);
            $('#edit-name').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#submit').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#edit-name').css('margin-top', '-16px');
        });

        $('a.edit-pass').click(function () {
            $('#view-pass').addClass('hidden').next().stop(false, true).fadeIn(200);
            $('#edit-pass').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#submit').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#edit-pass').css('margin-top', '-16px');
        });

        $('a.edit-address').click(function () {
            $('#view-address').addClass('hidden').next().stop(false, true).fadeIn(200);
            $('#edit-address').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#submit').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#edit-address').css('margin-top', '-16px');
        });

        $('a.edit-phone').click(function () {
            $('#view-phone').addClass('hidden').next().stop(false, true).fadeIn(200);
            $('#edit-phone').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#submit').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#edit-phone').css('margin-top', '-16px');
        });

        $('a.edit-avatar').click(function () {
            $('#edit-avatar').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#submit').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#edit-avatar').css('margin-top', '-16px');
        });

        $('#HuyBo').click(function () {
            $('#edit-email').addClass('hidden').next().stop(false, true).fadeIn(200);
            $('#view-email').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#submit').addClass('hidden').next().stop(false, true).fadeIn(200);

            $('#edit-name').addClass('hidden').next().stop(false, true).fadeIn(200);
            $('#view-name').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#submit').addClass('hidden').next().stop(false, true).fadeIn(200);

            $('#edit-pass').addClass('hidden').next().stop(false, true).fadeIn(200);
            $('#view-pass').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#submit').addClass('hidden').next().stop(false, true).fadeIn(200);

            $('#edit-address').addClass('hidden').next().stop(false, true).fadeIn(200);
            $('#view-address').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#submit').addClass('hidden').next().stop(false, true).fadeIn(200);

            $('#edit-phone').addClass('hidden').next().stop(false, true).fadeIn(200);
            $('#view-phone').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#submit').addClass('hidden').next().stop(false, true).fadeIn(200);

            $('#edit-avatar').addClass('hidden').next().stop(false, true).fadeIn(200);
            $('#submit').addClass('hidden').next().stop(false, true).fadeIn(200);

        });

        //shopping cart
        $('.tai-nha').click(function () {
            $('#list-bank').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#list-bank').addClass('hidden').next().stop(false, true).fadeIn(200);
        });

        $('.credit-cart').click(function () {
            $('#list-bank').removeClass('hidden').next().stop(false, true).fadeIn(100);
            $('#list-bank').addClass('hidden').next().stop(false, true).fadeIn(200);
        });

        $('.chuyen-khoan').click(function () {
            $('#list-bank').removeClass('hidden').next().stop(false, true).fadeIn(100);
        });




        $('a.newAddress').click(function () {
            $('#address').addClass('hidden').next().stop(false, true).fadeIn(200);
            $('#newAddress').removeClass('hidden').next().stop(false, true).fadeIn(100);
        });

        $('a.editAddress').click(function () {
            $('#address').addClass('hidden').next().stop(false, true).fadeIn(200);
            $('#editAddress').removeClass('hidden').next().stop(false, true).fadeIn(100);
        });

        $('#HuyBo').click(function () {
            $('#newAddress').addClass('hidden').next().stop(false, true).fadeIn(200);
            $('#address').removeClass('hidden').next().stop(false, true).fadeIn(100);
        });



        $('#HuyBo-editAddress').click(function () {
            $('#editAddress').addClass('hidden').next().stop(false, true).fadeIn(200);
            $('#address').removeClass('hidden').next().stop(false, true).fadeIn(100);
        });

        //DetailProduct message
        $('a.close-message').click(function () {
            $('#box-message').addClass('hidden').next().stop(false, true).fadeIn(200);
        })

        $('#btn-buy').click(function () {
            $('#box-message').removeClass('hidden').next().stop(false, true).fadeIn(100);
        })
    });

})(jQuery);

(function ($) {

    
	
	$(window).load(function(){
		//footer
		if ($(window).width() < 1024) { 
			$('#deal').css('display','none');
		}
		_height = $('#deal').outerHeight();
		$('#deal').animate({bottom:'-'+_height},500);

		$('.show-d').click(function(){
			el = $('.show-d, .close-d');
			if(el.hasClass('hiden') && el.hasClass('close-d')){
				$('#deal').stop().animate({bottom:'-'+_height},500,function(){
					el.removeClass('hide');
					el.removeClass('close-d');
					el.addClass('show-d');
				});
			}else{
				el.addClass('hiden');
				el.removeClass('show-d');
				el.addClass('close-d');
				$('#deal').stop().animate({bottom:0},500);
			}
			
		});
	});

})(jQuery);
